package zhongbo.java.air.monitor.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
import zhongbo.java.air.monitor.web.AlertZoneWebSocket;
import zhongbo.java.air.monitor.web.LiveWebsocket;


@Component
@Slf4j
public class RedisSubscribeLogChanelListener implements MessageListener {
   @Autowired
    private LiveWebsocket liveWebsocket;
   @Autowired
   private AlertZoneWebSocket alertZoneWebSocket;
    @Override
    public void onMessage(Message message, byte[] bytes) {
        String channel = new String(message.getChannel());
        String body = new String(message.getBody());
        log.info("收到Redis日志消息 - 频道: {}, 内容: {}", channel, body);
        //广播最新航迹点
        liveWebsocket.broadcast(body);
        alertZoneWebSocket.broadcast(body);
    }
}

